package com.api.aiyh_kafang.service;


import aiyh.utils.zwl.common.ToolUtil;
import org.apache.axiom.util.base64.Base64Utils;
import weaver.file.ImageFileManager;

import java.util.Map;
import java.util.UUID;

/**
 * @author EBU7-dev1-ayh
 * @create 2021/10/8 0008 13:36
 * 业务逻辑处理
 */


public class UploadByBase64Service {
	public int uploadImage(Map<String, String> param) {
		ToolUtil toolUtil = new ToolUtil();
		String base64 = String.valueOf(param.get("base64")).replaceAll(" ", "+");;
		ImageFileManager fileManager = new ImageFileManager();
		byte[] data = null;
		data = Base64Utils.decode(base64);
		fileManager.setData(data);
		String fileName = "" + System.currentTimeMillis() + UUID.randomUUID() + ".jpg";
		fileManager.setImagFileName(fileName);
		int i = fileManager.saveImageFile();
		toolUtil.writeErrorLog("生成的图片的id：" + i);
		return i;
	}
}
